<html ng-app="app">

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="msapplication-tap-highlight" content="no"/>
    <script type="text/javascript" src="/files/jquery-1.9.1.min.js"></script>
    <title>智能防反系统</title>
    <script src="/config.js"></script>
    <style type="text/css">
        .alertB {
            position: fixed;
            z-index: 9999999999999999999999999999;
            width: 150px;
            height: 150px;
            top: 45%;
            left: 50%;
            margin-top: -75px;
            margin-left: -75px;
            border-radius: 5px;
            overflow: hidden;
        }

        .alertB .alertBackgroundB {
            filter: alpha(opacity=50);
            -moz-opacity: 0.5;
            opacity: 0.5;
            background: #000;
            height: 100%;
            width: 100%;
        }

        .alertB img {
            position: absolute;
            top: 10px;
            left: 29px;
        }

        .alertB .alertTextB {
            position: absolute;
            top: 100px;
            width: 150px;
            text-align: center;
            font-size: 18px;
            color: #fff;
            filter: alpha(opacity=95);
            -moz-opacity: 0.95;
            opacity: 0.95;
        }
    </style>
</head>
<body>
<div>
    <div style="position: relative; text-align:center;height: 15vw; word-wrap: break-word; word-break: break-all; color: rgb(0, 0, 0); background-color: white; border-width: 0px; border-top-style: solid; border-color: rgb(230, 230, 230);">
        <input type="number" maxlength="20" class='J_security_code' placeholder="请输入可控ID白名单 一次添加一个ID"
               style="padding: 0px 12px; position: absolute; top: 1vw; left: 0vw; width: 72vw; height: 12vw; line-height: 6.5vw; border-style: solid; border-width: 1px; border-radius: 0.5vh; border-color: rgb(240, 240, 240); background-color: rgb(240, 240, 240); font-size: 4vw; -webkit-appearance: none;">
        <div style="position: relative; top: 0.5vh;left: 80vw; width: 15vw; line-height: 11vw; font-size: 4vw; display: flex; border-radius: 2vw;">
            <div onclick="sendsearchsys()"
                 style="display: block; -webkit-box-flex: 1; flex: 1 1 0%; text-decoration: none; -webkit-tap-highlight-color: transparent; position: relative; margin-bottom: 0px; color: rgb(255, 255, 255); border-width: 0px; border-top-style: solid; border-color: rgb(230, 230, 230); background-color: rgb(64, 112, 251); border-radius: 1vw;">
                添加
            </div>
        </div>
    </div>
</div>
<div class="searchsys"
     style="position:absolute;top: 10%;left: 6%;right: 6%;bottom: 3%;border-radius:1vh;z-index:100;display:block;">
    <div style="background:#fff; width:100%;height:100%;">
        <div class="searchsys_Title" style="color: rgb(64, 112, 251);width: 100%; font-size: 2vh; text-align:center;">
            防反系统白名单
        </div>
        <div class="searchsys_content"
             style="width: auto; font-size: 2vh; text-align:center; margin:0 2vh;position:relative;">
        </div>
    </div>
</div>
<div id="msg" class="alertB" style="display: none;">
    <div class="alertBackgroundB"></div>
    <img id="d" src="/files/images/center/alert1.png" style="display: none">
    <img id="x" src="/files/images/center/alert2.png" style="display: none;">
    <div class="alertTextB"></div>
</div>
<script>
    function sendsearchsys() {
        var securityCode = $(".J_security_code").val();
        if (securityCode.length > 0) {
            zn_ajax(
                '/index/prevention/Preventionquery',
                {'e': securityCode},
                function (e) {
                    if (e.result == 0) {
                        showmsg(e.msg, 1);
                        getWhiteList();
                    } else {
                        showmsg(e.msg, 0);
                    }
                });
        }
    }

    function getWhiteList() {
        zn_ajax(
            '/index/prevention/PreventiongetWhiteList',
            {'id': '1'},
            function (e) {
                if (e.result == 0) {
                    var a = e.data;
                    $('.searchsys_content').html('');
                    if (a.length > 0) {
                        for (var j = 0, len = a.length; j < len; j++) {
                            $('.searchsys_content').append('<p style="margin:0;height:4vh;line-height:4vh;"><span style="position:absolute;left:0;"><img src="' + a[j].img + '" style="width:6vw;height:6vw;"></span><span>' + a[j].nickname + '</span><span style="color: #df0000;position:absolute;right:0;z-index:1000;" onclick="overcontrol(' + a[j].id + ');">' + a[j].isopen + '</span></p>');
                        }
                    } else {
                        $('.searchsys_content').html('');
                        $('.searchsys_content').append('<p >白名单列表空</p>');
                    }
                } else {
                    $('.searchsys_content').html('');
                    $('.searchsys_content').append('<p >你没有此权限</p>');
                }
            });
    }

    function overcontrol(id) {
        zn_ajax(
            '/index/prevention/Preventionovercontrol',
            {'id': id},
            function (e) {
                if (e.result == 0) {
                    showmsg(e.msg, 1);
                    getWhiteList();
                } else {
                    showmsg(e.msg, 0);
                }
            });
    }

    function showmsg(msg, id) {
        $(".alertB").css('display', 'block');
        if (id == 1) {
            $(".alertB>#d").css('display', 'block');
        } else {
            $(".alertB>#x").css('display', 'block');
        }
        $('.alertB>.alertTextB').html(msg);
        setTimeout(function () {
            $(".alertB").css('display', 'none');
            $(".alertB>#d").css('display', 'none');
            $(".alertB>#x").css('display', 'none');
        }, 1500);
    }

    window.onload = function () {
        getWhiteList();
    };


    function zn_ajax(url, data, callback) {
        $.ajax({
            type: "post",
            url: JONO_HOST + url,
            dataType: 'JSON',
            data: data,
            async: false,
            success: callback,
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                msg(errorThrown);
            },
            beforeSend : function(request) {
                request.setRequestHeader("Authorization",window.localStorage.getItem("token"));
            },
        });
    }
</script>
</body>
</html>


